<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${packageName}.dao.${className}Dao" >
    <resultMap id="BaseResultMap" type="${packageName}.entity.${className}" >
    <#list xml as a>
        <#if a_index==0>
        <id column="${a.field}" property="${a.fields}" jdbcType="${a.type}" />
        <#else>
        <result column="${a.field}" property="${a.fields}" jdbcType="${a.type}" />
        </#if>
    </#list>
    </resultMap>

    <sql id="Base_Column_List" >
    <#list xml as a>
        ${a.field}<#if a_has_next>,</#if>
    </#list>
    </sql>

    ${o}<select id="get" resultMap="BaseResultMap" parameterType="java.lang.<#list xml as a><#if a_index ==0>${a.types}</#if></#list>">
        select
        <include refid="Base_Column_List" />
        from ${table}
        where id =  <#list xml as a> <#if a_index ==0>#${m}${a.field},jdbcType=${a.type}${n}</#if> </#list>
    </select> ${p}

    <select id="get" resultMap="BaseResultMap" parameterType="${packageName}.entity.${className}">
        select
        <include refid="Base_Column_List" />
        from ${table}
        where  "修改为删除标记字段" = #${m}删除字段设定值${n}
        <#list xml as a>
         <#if a_index ==0>
          <if test="${a.fields} != null and ''!=${a.fields}">
             and ${a.field} = #${m}${a.field},jdbcType=${a.type}${n}
          </if>
         </#if>
         <#if (a_index >0)>
           <if test="${a.fields} != null and ''!=${a.fields}">
               and ${a.field} = #${m}${a.field},jdbcType=${a.type}${n}
            </if>
          </#if>
        </#list>
    </select>

    <select id="findList" resultMap="BaseResultMap" parameterType="${packageName}.entity.${className}">
        select
        <include refid="Base_Column_List" />
        from ${table}
        where "修改为删除标记字段" = #${m}删除字段设定值${n}
    <#list xml as a>
        <#if a_index ==0>
           <if test="${a.fields} != null and ''!=${a.fields}">
             and ${a.field} = #${m}${a.field},jdbcType=${a.type}${n}
           </if>
        </#if>
        <#if (a_index >0)>
           <if test="${a.fields} != null and ''!=${a.fields}">
             and ${a.field} = #${m}${a.field},jdbcType=${a.type}${n}
           </if>
        </#if>
    </#list>
    </select>

    <insert id="insert" parameterType="${packageName}.entity.${className}">
        insert into ${table}(
            <include refid="Base_Column_List" />
        ) values (
            <#list xml as a>
             #${m}${a.fields}${n}<#if a_has_next>,</#if>
            </#list>
        )
    </insert>

    <update id="update" parameterType="${packageName}.entity.${className}">
        update ${table} set
        <#list xml as a>
            ${a.field}=#${m}${a.fields}${n}<#if a_has_next>,</#if>
        </#list>
        where id =  <#list xml as a> <#if a_index ==0>#${m}${a.field},jdbcType=${a.type}${n}</#if> </#list>
    </update>

    <update id="delete" parameterType="java.lang.<#list xml as a><#if a_index ==0>${a.types}</#if></#list>">
        update ${table} set
        "修改为删除标记字段" = #${m}传入映射字段值${n}
        WHERE id = <#list xml as a> <#if a_index ==0>#${m}${a.field},jdbcType=${a.type}${n}</#if> </#list>
    </update>

    ${o}<update id="delete" parameterType="${packageName}.entity.${className}"">
        update ${table} set
        "修改为删除标记字段" = #${m}映射字段${n}
        where 1=1
    <#list xml as a>
    <#if a_index ==0>
        <if test="${a.fields} != null and ''!=${a.fields}">
            and ${a.field} = #${m}${a.field},jdbcType=${a.type}${n}
        </if>
    </#if>
    <#if (a_index >0)>
        <if test="${a.fields} != null and ''!=${a.fields}">
            and ${a.field} = #${m}${a.field},jdbcType=${a.type}${n}
        </if>
    </#if>
    </#list>
    </update>${p}

</mapper>